/* 
精美视频页面
*/

<template>
  <view>
    <view class="video_tab">
      <!-- 标题 开始 -->
      <view class="video_tab_title">
        <!-- 分段器 开始 -->
        <view class="title_inner">
          <uni-segmented-control
            :current="current"
            :values="items.map((v) => v.title)"
            @clickItem="onClickItem"
            style-type="text"
            active-color="#d4237a"
          >
          </uni-segmented-control>
        </view>
        <!-- 分段器 结束 -->
        <!-- 搜索按钮 -->
        <view class="iconfont iconsearch"></view>
      </view>
      <!-- 标题 结束 -->

      <!-- 内容 开始 -->
      <view class="video_tab_content">
        <view v-if="current < 4">
          <videoMain
            :urlobj="{ url: items[current].url, params: items[current].params }"
          ></videoMain>
        </view>
        <view v-if="current === 4">
          <videoCategory></videoCategory>
        </view>
      </view>
      <!-- 内容 结束 -->
    </view>
  </view>
</template>

<script>
import { uniSegmentedControl } from '@dcloudio/uni-ui';
import videoMain from './video-main';
import videoCategory from './video-category';

export default {
  components: {
    uniSegmentedControl,
    videoMain,
    videoCategory
  },
  data() {
    return {
      // 分段器
      items: [
        {
          title: '推荐',
          url: 'http://157.122.54.189:9088/videoimg/v1/videowp/featured',
          params: { limit: 30, skip: 0, order: 'hot' }
        },
        {
          title: '娱乐',
          url:
            'http://157.122.54.189:9088/videoimg/v1/videowp/category/59b25abbe7bce76bc834198a',
          params: { limit: 30, skip: 0, order: 'new' }
        },
        {
          title: '最新',
          url: 'http://157.122.54.189:9088/videoimg/v1/videowp/videowp',
          params: { limit: 30, skip: 0, order: 'new' }
        },
        {
          title: '热门',
          url: 'http://157.122.54.189:9088/videoimg/v1/videowp/videowp',
          params: { limit: 30, skip: 0, order: 'hot' }
        },
        {
          title: '分类',
          url: 'http://157.122.54.189:9088/videoimg/v1/videowp/category',
          params: {}
        }
      ],
      current: 0
    };
  },
  methods: {
    onClickItem(e) {
      if (this.current !== e.currentIndex) {
        this.current = e.currentIndex;
      }
    }
  }
};
</script>

<style lang="scss">
// 分段器
.video_tab {
  .video_tab_title {
    position: relative;
    // 分段器
    .title_inner {
      width: 60%;
      margin: 0 auto;
    }
    .iconsearch {
      position: absolute;
      top: 50%;
      transform: translateY(-50%);
      right: 5%;
    }
  }
  .video_tab_content {
  }
}
</style>